# -*- coding: utf-8 -*-

from PySide.QtCore import *
from PySide.QtGui import *
from PySide.QtSql import *
import sys
import site

QTextCodec.setCodecForTr(QTextCodec.codecForName("utf8"))

class DBManager():
    def __init__(self):
        isok=self.createConnection()

    def createConnection(self):
        self.db=QSqlDatabase.addDatabase("QMYSQL")
        self.db.setHostName("localhost")
        self.db.setUserName("root")
        self.db.setPassword("root")

        isok=False
        if self.db.open():
            print "Success to open mysql"
            isok=True
        else:
            print "Fail to open mysql"
            isok=False
        return isok

if __name__=="__main__":
    site_pack_path = site.getsitepackages()[1]
    QApplication.addLibraryPath('{0}\\PySide\\plugins'.format(site_pack_path))
    app = QApplication(sys.argv)
    list=app.libraryPaths()
    print list
    db=DBManager()
    sys.exit(app.exec_())

